﻿CREATE VIEW [dbo].[Issues]
	AS 
SELECT     
	I.IssueId, 
	I.Description AS Issue, 
	S.Description AS Scope, 
	C.Description AS Category,
	IT.Severity, 
	INF.Server,
	INF.ServerId,
	INF.Service,
	INF.ServiceId,
	INF.[Database],
	INF.DatabaseId,
	R.Description AS Recommendation, 
	R.HowToTitle AS HowToTitle,
	R.HowToUrl AS HowToURL
FROM         
    dbo.Issue AS I 
		INNER JOIN
    dbo.IssueType AS IT ON I.IssueTypeId = IT.IssueTypeId 
		INNER JOIN
	dbo.Category AS C ON IT.CategoryId = C.CategoryId
		INNER JOIN
	dbo.Scope AS S ON S.ScopeId = IT.ScopeId 
		LEFT OUTER JOIN
    dbo.RecommendationIssueType AS RIS ON IT.IssueTypeId = RIS.IssueTypeId
		LEFT OUTER JOIN
	dbo.Recommendation AS R ON R.RecommendationId = RIS.RecommendationId 
		CROSS APPLY 
	dbo.GetTargetInformation(I.TargetId, S.ScopeId) AS INF
    